import { Column, Entity, Index, JoinColumn, ManyToOne } from "typeorm";
import { CommonEntity, CommonStatus } from "~/common/entity/common.entity";
import { TenantEntity } from "~/modules/tenant/tenant.entity";

@Entity('ah_banner')
@Index(['id'])
export class BannerEntity extends CommonEntity {
	@Column({ type: "varchar", length: 255, comment: "Banner 标题", nullable: true })
	title: string;

	// Banner 图片地址
	@Column({ type: "varchar", length: 500, comment: "图片 URL", name: "image_url" })
	imageUrl: string;

	// 点击跳转链接
	@Column({ type: "varchar", length: 500, nullable: true, comment: "点击跳转的链接地址", name: "link_url" })
	linkUrl: string;

	// 显示排序
	@Column({ type: "int", default: 0, comment: "显示排序", name: "sort_order" })
	sortOrder: number;

	// 是否启用
	@Column({ type: 'tinyint', width: 1, default: CommonStatus.YES, comment: "是否启用", name: "is_active" })
	isActive: CommonStatus;

	@Column({ type: "varchar", length: 255, nullable: true, comment: "备注" })
	remark: string;

	@ManyToOne(() => TenantEntity, (tenant) => tenant.banners)
	@JoinColumn({ name: 'tenant_id' })
	tenant: TenantEntity;
}